home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2008 February / PCWFEB08.iso / Software / Resources / Utilities / Partition Logic 0.68 / partlogic-0.68.iso / system / headers / sys / window.h < prev   
Encoding:
C/C++ Source or Header  |  2007-05-10  |  8.1 KB  |  258 lines

  1. // 
  2. //  Visopsys
  3. //  Copyright (C) 1998-2007 J. Andrew McLaughlin
  4. //  
  5. //  This library is free software; you can redistribute it and/or modify it
  6. //  under the terms of the GNU Lesser General Public License as published by
  7. //  the Free Software Foundation; either version 2.1 of the License, or (at
  8. //  your option) any later version.
  9. //
  10. //  This library is distributed in the hope that it will be useful, but
  11. //  WITHOUT ANY WARRANTY; without even the implied warranty of
  12. //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
  13. //  General Public License for more details.
  14. //
  15. //  You should have received a copy of the GNU Lesser General Public License
  16. //  along with this library; if not, write to the Free Software Foundation,
  17. //  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. //
  19. //  window.h
  20. //
  21.  
  22. // This file describes things needed for interaction with the kernel's
  23. // window manager and the Visopsys GUI.
  24.  
  25. #if !defined(_WINDOW_H)
  26.  
  27. #include <sys/image.h>
  28. #include <sys/loader.h>
  29. #include <sys/progress.h>
  30. #include <sys/stream.h>
  31.  
  32. #ifndef _X_
  33. #define _X_
  34. #endif
  35.  
  36. // Window events/masks.  This first batch are "tier 2" events, produced by
  37. // windows, widgets, etc. to indicate that some more abstract thing has
  38. // happened.
  39. #define EVENT_MASK_WINDOW                 0x00F00000
  40. #define EVENT_WINDOW_RESIZE               0x00400000
  41. #define EVENT_WINDOW_CLOSE                0x00200000
  42. #define EVENT_WINDOW_MINIMIZE             0x00100000
  43. #define EVENT_SELECTION                   0x00020000
  44. #define EVENT_CURSOR_MOVE                 0x00010000
  45. // And these are "tier 1" events, produced by direct actions of the user.
  46. #define EVENT_MASK_KEY                    0x0000F000
  47. #define EVENT_KEY_UP                      0x00002000
  48. #define EVENT_KEY_DOWN                    0x00001000
  49. #define EVENT_MASK_MOUSE                  0x00000FFF
  50. #define EVENT_MOUSE_ENTER                 0x00000200
  51. #define EVENT_MOUSE_EXIT                  0x00000100
  52. #define EVENT_MOUSE_DRAG                  0x00000080
  53. #define EVENT_MOUSE_MOVE                  0x00000040
  54. #define EVENT_MOUSE_RIGHTUP               0x00000020
  55. #define EVENT_MOUSE_RIGHTDOWN             0x00000010
  56. #define EVENT_MOUSE_RIGHT                 (EVENT_MOUSE_RIGHTUP |    \
  57.                        EVENT_MOUSE_RIGHTDOWN)
  58. #define EVENT_MOUSE_MIDDLEUP              0x00000008
  59. #define EVENT_MOUSE_MIDDLEDOWN            0x00000004
  60. #define EVENT_MOUSE_MIDDLE                (EVENT_MOUSE_MIDDLEUP |   \
  61.                        EVENT_MOUSE_MIDDLEDOWN)
  62. #define EVENT_MOUSE_LEFTUP                0x00000002
  63. #define EVENT_MOUSE_LEFTDOWN              0x00000001
  64. #define EVENT_MOUSE_LEFT                  (EVENT_MOUSE_LEFTUP |     \
  65.                        EVENT_MOUSE_LEFTDOWN)
  66. #define EVENT_MOUSE_DOWN                  (EVENT_MOUSE_LEFTDOWN |   \
  67.                        EVENT_MOUSE_MIDDLEDOWN | \
  68.                        EVENT_MOUSE_RIGHTDOWN)
  69. #define EVENT_MOUSE_UP                    (EVENT_MOUSE_LEFTUP |     \
  70.                        EVENT_MOUSE_MIDDLEUP |   \
  71.                        EVENT_MOUSE_RIGHTUP)
  72.  
  73. // The maximum numbers of window things
  74. #define WINDOW_MAXWINDOWS                 256
  75. #define WINDOW_MAX_EVENTS                 512
  76. #define WINDOW_MAX_EVENTHANDLERS          256
  77. #define WINDOW_MAX_TITLE_LENGTH           80
  78. #define WINDOW_MAX_LABEL_LENGTH           80
  79.  
  80. // Flags for window components
  81. #define WINDOW_COMPFLAG_CLICKABLECURSOR   0x80
  82. #define WINDOW_COMPFLAG_CUSTOMBACKGROUND  0x40
  83. #define WINDOW_COMPFLAG_CUSTOMFOREGROUND  0x20
  84. #define WINDOW_COMPFLAG_STICKYFOCUS       0x10
  85. #define WINDOW_COMPFLAG_HASBORDER         0x08
  86. #define WINDOW_COMPFLAG_CANFOCUS          0x04
  87. #define WINDOW_COMPFLAG_FIXEDHEIGHT       0x02
  88. #define WINDOW_COMPFLAG_FIXEDWIDTH        0x01
  89.  
  90. // Flags for file browsing widgets/dialogs.
  91. #define WINFILEBROWSE_CAN_CD              0x01
  92. #define WINFILEBROWSE_CAN_DEL             0x02
  93. #define WINFILEBROWSE_ALL                 (WINFILEBROWSE_CAN_CD | \
  94.                                            WINFILEBROWSE_CAN_DEL)
  95.  
  96. // Some image file names for dialog boxes
  97. #define INFOIMAGE_NAME                    "/system/icons/infoicon.bmp"
  98. #define ERRORIMAGE_NAME                   "/system/icons/bangicon.bmp"
  99. #define QUESTIMAGE_NAME                   "/system/icons/questicon.bmp"
  100. #define WAITIMAGE_NAME                    "/system/mouse/mousebsy.bmp"
  101.  
  102. // An "object key".  Really a pointer to an object in kernel memory, but
  103. // of course not usable by applications other than as a reference
  104. typedef volatile void * objectKey;
  105.  
  106. // These describe the X orientation and Y orientation of a component,
  107. // respectively, within its grid cell
  108.  
  109. typedef enum {
  110.   orient_left, orient_center, orient_right
  111. }  componentXOrientation;
  112.  
  113. typedef enum {
  114.   orient_top, orient_middle, orient_bottom
  115. }  componentYOrientation;
  116.  
  117. // This structure is needed to describe parameters consistent to all
  118. // window components
  119. typedef struct {
  120.   int gridX;
  121.   int gridY;
  122.   int gridWidth;
  123.   int gridHeight;
  124.   int padLeft;
  125.   int padRight;
  126.   int padTop;
  127.   int padBottom;
  128.   int flags;
  129.   componentXOrientation orientationX;
  130.   componentYOrientation orientationY;
  131.   color foreground;
  132.   color background;
  133.   objectKey font;
  134.  
  135. } componentParameters;
  136.  
  137. // A structure for containing various types of window events.
  138. typedef struct {
  139.   unsigned type;
  140.   int xPosition;
  141.   int yPosition;
  142.   unsigned key;
  143.  
  144. } windowEvent;
  145.  
  146. // A structure for a queue of window events as a stream.
  147. typedef struct {
  148.   objectKey component;
  149.   stream s;
  150.  
  151. } windowEventStream;
  152.  
  153. // Types of drawing operations
  154. typedef enum {
  155.   draw_pixel, draw_line, draw_rect, draw_oval, draw_image, draw_text
  156. } drawOperation;
  157.  
  158. // Parameters for any drawing operations
  159. typedef struct {
  160.   drawOperation operation;
  161.   drawMode mode;
  162.   color foreground;
  163.   color background;
  164.   int xCoord1;
  165.   int yCoord1;
  166.   int xCoord2;
  167.   int yCoord2;
  168.   unsigned width;
  169.   unsigned height;
  170.   int thickness;
  171.   int fill;
  172.   objectKey font;
  173.   void *data;
  174.  
  175. } windowDrawParameters;
  176.  
  177. // Types of scroll bars
  178. typedef enum {
  179.   scrollbar_vertical, scrollbar_horizontal
  180. } scrollBarType;
  181.  
  182. // A structure for specifying display percentage and display position
  183. // in scroll bar components
  184. typedef struct {
  185.   unsigned displayPercent;
  186.   unsigned positionPercent;
  187.  
  188. } scrollBarState;
  189.  
  190. // Types of window list displays
  191. typedef enum {
  192.   windowlist_textonly, windowlist_icononly
  193. } windowListType;
  194.  
  195. typedef struct {
  196.   char text[WINDOW_MAX_LABEL_LENGTH];
  197.   image iconImage;
  198.  
  199. } listItemParameters;
  200.  
  201. typedef struct _windowFileList {
  202.   objectKey key;
  203.   void *fileEntries;
  204.   int numFileEntries;
  205.   int browseFlags;
  206.   void (*selectionCallback)(file *, char *, loaderFileClass *);
  207.  
  208.   // Externally-callable service routines
  209.   int (*eventHandler) (struct _windowFileList *, windowEvent *);
  210.   int (*update) (struct _windowFileList *, const char *);
  211.   int (*destroy) (struct _windowFileList *);
  212.  
  213. } windowFileList;
  214.  
  215. typedef struct {
  216.   char text[WINDOW_MAX_LABEL_LENGTH];
  217.   objectKey key;
  218.  
  219. } windowMenuItem;
  220.  
  221. typedef struct {
  222.   int numItems;
  223.   windowMenuItem items[];
  224.  
  225. } windowMenuContents;
  226.  
  227. void windowCenterDialog(objectKey, objectKey);
  228. int windowClearEventHandler(objectKey);
  229. int windowClearEventHandlers(void);
  230. void windowGuiRun(void);
  231. void windowGuiStop(void);
  232. int windowGuiThread(void);
  233. int windowGuiThreadPid(void);
  234. objectKey windowNewBannerDialog(objectKey, const char *, const char *);
  235. int windowNewChoiceDialog(objectKey, const char *, const char *, char *[],
  236.               int, int);
  237. int windowNewColorDialog(objectKey, color *);
  238. int windowNewErrorDialog(objectKey, const char *, const char *);
  239. int windowNewFileDialog(objectKey, const char *, const char *, const char *,
  240.             char *, unsigned);
  241. windowFileList *windowNewFileList(objectKey, windowListType, int, int,
  242.                   const char *, int, void *,
  243.                   componentParameters *);
  244. int windowNewInfoDialog(objectKey, const char *, const char *);
  245. int windowNewPasswordDialog(objectKey, const char *, const char *, int,
  246.                 char *);
  247. objectKey windowNewProgressDialog(objectKey, const char *, progress *);
  248. int windowNewPromptDialog(objectKey, const char *, const char *, int, int,
  249.               char *);
  250. int windowNewQueryDialog(objectKey, const char *, const char *);
  251. int windowNewRadioDialog(objectKey, const char *, const char *, char *[],
  252.              int, int);
  253. int windowProgressDialogDestroy(objectKey);
  254. int windowRegisterEventHandler(objectKey, void (*)(objectKey, windowEvent *));
  255.  
  256. #define _WINDOW_H
  257. #endif
  258.